package com.msb.test14;

import java.io.*;
import java.net.Socket;

//客户端
public class TestClient {
    public static void main(String[] args) throws IOException {
        System.out.println("客户端启动");
        //1.套接字传ip和端口号
        Socket s=new Socket("172.16.133.188",8888);
        //2.获取输出流
        OutputStream os = s.getOutputStream();
        DataOutputStream dos=new DataOutputStream(os);

        InputStream is = s.getInputStream();
        DataInputStream dis=new DataInputStream(is);

        //3.传送数据
        dos.writeUTF("你好服务器端");
        String sss = dis.readUTF();
        System.out.println(sss);
        //4.流、资源网络关闭
        dos.close();
        dis.close();
        is.close();
        dos.close();
        os.close();
        s.close();

    }
}
